package com.common.security.exceptions;

import com.common.security.abstracts.AbstractException;

/**
 * Error code range: 1081 - 1100
 * 
 * @author Ady
 *
 */
public class ParserException extends AbstractException {
	private static final long serialVersionUID = 1L;
	
	public static final int RESPONSE_MATCH_ERROR = 1081;
	private static final String MESSAGE_RESPONSE_MATCH_ERROR = "The response doesn't match the action";
	
	public static final int STREAM_ERROR = 1082;
	private static final String MESSAGE_STREAM_ERROR = "There was a problem while opening the stream";
	
	public static final int MULTIPLE_ACTIONS_PROVIDED = 1083;
	private static final String MESSAGE_MULTIPLE_ACTIONS_PROVIDED = "More than one Action tag was provided";
	
	public static final int NO_ACTION_PROVIDED = 1084;
	private static final String MESSAGE_NO_ACTION_PROVIDED = "The action is mandatory but it was not provided";

	public static final int MULTIPLE_CONTENTS_PROVIDED = 1085;
	private static final String MESSAGE_MULTIPLE_CONTENTS_PROVIDED = "More than one Content tag was provided";
	
	public static final int NO_CONTENT_PROVIDED = 1086;
	private static final String MESSAGE_NO_CONTENT_PROVIDED = "The content is mandatory but it was not provided";
	
	public static final int CONTENT_BAD_FORMAT = 1087;
	private static final String MESSAGE_CONTENT_BAD_FORMAT = "The content was provided in a bad format";
	
	public static final int RESPONSE_BAD_FORMAT = 1088;
	private static final String MESSAGE_RESPONSE_BAD_FORMAT = "The response was created in a bad format";
	
	public static final int CONVERSION_EXCEPTION = 1089;
	private static final String MESSAGE_CONVERSION_EXCEPTION = "The parser was not able to convert one of the values";
	
	public ParserException(int code) {
		super(code, getMessage(code));
	}
	
	private static String getMessage(int code) {
		switch (code) {
			case RESPONSE_MATCH_ERROR: {
				return MESSAGE_RESPONSE_MATCH_ERROR;
			}
			case STREAM_ERROR: {
				return MESSAGE_STREAM_ERROR;
			}
			case MULTIPLE_ACTIONS_PROVIDED: {
				return MESSAGE_MULTIPLE_ACTIONS_PROVIDED;
			}
			case NO_ACTION_PROVIDED: {
				return MESSAGE_NO_ACTION_PROVIDED;
			}
			case MULTIPLE_CONTENTS_PROVIDED: {
				return MESSAGE_MULTIPLE_CONTENTS_PROVIDED;
			}
			case NO_CONTENT_PROVIDED: {
				return MESSAGE_NO_CONTENT_PROVIDED;
			}
			case CONTENT_BAD_FORMAT: {
				return MESSAGE_CONTENT_BAD_FORMAT;
			}
			case RESPONSE_BAD_FORMAT: {
				return MESSAGE_RESPONSE_BAD_FORMAT;
			}
			case CONVERSION_EXCEPTION: {
				return MESSAGE_CONVERSION_EXCEPTION;
			}
			default: {
				return MESSAGE_ERROR_NOT_FOUND;
			}
		}
	}
}
